#include "../Include/io_pub.h"
#include "../Include/common_pub.h"
#include "../StudentModule/student.h"
#include "../CourseModule/course.h"
#include <stdio.h>

extern Student students[MAX_STUDENTS];
extern int student_count;
extern Course courses[MAX_COURSES_NUM];
extern int course_count;

int input_from_keyboard() {
    printf("=== 键盘输入模式 ===\n");
    printf("请依次输入学生和课程信息\n");
    
    // 示例数据
    add_student("1001", "张三");
    add_student("1002", "李四");
    add_student("1003", "王五");
    
    add_course("C001", "Linux编程", "必修", 64, 3.0, 50);
    add_course("C002", "数据结构", "必修", 72, 4.0, 40);
    add_course("C003", "数据库", "选修", 48, 2.5, 30);
    
    log_message(LOG_INFO, "键盘输入模式初始化完成");
    return SUCCESS;
}

int initialize_data(InputMode mode) {
    switch (mode) {
        case INPUT_FROM_FILE:
            load_students_from_file();
            load_courses_from_file();
            break;
        case INPUT_FROM_KEYBOARD:
            input_from_keyboard();
            break;
        default:
            log_message(LOG_ERROR, "未知的数据输入模式");
            return ERROR;
    }
    return SUCCESS;
}
